<html>
<head>
<#assign basePath=request.contextPath>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理系统</title>
<#include "/WEB-INF/views/template/bootMainCss.ftl" parse=true encoding="utf-8">
    <link href="${basePath}/bootstrap/css/form.lzy.css" rel="stylesheet">
    <link href="/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <style>
        .search{margin-left: 30px;}
        .btn{margin-left: 10px;}
    </style>
</head>
<body>
<shiro:hasPermission name="sys:product:add">
    <input id="p_add"  value="1" type="hidden">
</shiro:hasPermission>
<shiro:hasPermission name="sys:product:update">
    <input id="p_update"  value="1" type="hidden">
</shiro:hasPermission>

<div class="panel panel-lzy">
    <div class="panel-body">
        <h5 class="tips-lzy">操作提示</h5>
        <ul class="tips-list-lzy">
            <li>◆&nbsp;<span>该页面展示了代言人、代理商管理和新增。</span></li>
        </ul>
    </div>
</div>

<div class="panel panel-f5">
    <div class="panel-body row name">
        <form id="myForm" class="form-inline form-margin-right">
            <div class="panel-heading">
                <button type="button" class="btn btn-primary" onclick="addLine();"><span class="fa fa-plus"></span> 新增</button>
                <input type="text" class="form-control search" id="price" placeholder="代理商姓名/手机号">
                <button type="button" class="btn btn-primary btn-sm btn" onclick="search(1)">查询</button>
            </div>
        </form>
    </div>

    <div class="panel panel-f5">
        <!-- 分页查询的地址-->
        <div class="panel-body panel-white">
            <input type="hidden" name="memberId" value="${memberId?c}" />
            <div class="table-responsive">
                <table id="myTable"
                       class="table table-hover"
                       data-url="${basePath}/admin/coupons/member/selectContract?memberId=${memberId?c}"
                       data-pageSize="10,50,100" data-method="GET">
                    <thead>
                    <!-- 需要循环的字段  对应mapper文件-->
                    <tr>
                        <th data-type="xuhao">序号</th>
                        <th data-field="phone">代理商手机</th>
                        <th data-field="name">姓名</th>
                        <th data-field="name">代理商编号</th>
                        <th data-field="name">所在地</th>
                        <th data-field="createTime" data-call="true">成为代理商时间</th>
                        <th  data-field="button" data-call="true">操作</th>
                    </tr>
                    </thead>
                    <tbody id="tbodyId">

                    </tbody>
                </table>
            </div>
            <!-- 分页条-->
            <div class="row">
                <div align="left" class="col-xs-6">
                    <div class="input-group">
                        <span class="input-group-addon" id="pageCount"></span> <select
                            id="pageSize" onchange="search(1)" class="form-control"
                            style="width: 100px"></select>
                    </div>
                </div>
                <div align="right" class="col-xs-6">
                    <ul class="pagination" id="pagination"></ul>
                </div>
            </div>
        </div>
    </div>
</div>

<#include "/WEB-INF/views/template/bootMainJs.ftl" parse=true encoding="utf-8">
<script type="text/javascript" src="${basePath}/bootstrap/js/utils.js" type="text/javascript"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/myPage.js"></script>
<!-- bootstrap-datetimepicker -->
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">

    //循环列表数据以及操作按钮
    function tableCallBack(data, id){
        if(id == 'button') {//增加操作按钮
            var _button = '<button type="button" class="btn btn-white btn-xs" onclick="viewMeal(' + data.id + ');">查看 </button> ';
            _button += '<button type="button" class="btn btn-white btn-xs" onclick="downMarket(' + data.id + ');" >删除</button> ';
            return _button;
        }
        else if(id == "banner"){
            return "<div class='shop-img'><img src='"+data.banner+"' height='50'><span>"+data.name+"</span></div>";
        }
        else {
            if(data[id] == null || data[id] == ''){
                return '';
            }else{
                return data[id];
            }
        }
    }

    //新增
    function addLine(){
        window.location.href='${basePath}/admin/product/level/add';
    }

    //查看
    function viewMeal(id){
        window.location.href='${basePath}/admin/product/info/view/'+id;
    }

    //删除
    function downMarket(id){
        layer.confirm('是否确定此操作？', {
            btn: ['确定','取消'] //按钮
        }, function() {
            $.ajax({
                type: 'GET',
                url: '${basePath}/admin/product/level/remove?id='+id,
                success: function (data) {
                    var data = JSON.parse(data);
                    if (data.code == '0') {
                        layer.alert('删除成功!', {
                            icon: 6
                        }, function(index){
                            layer.closeAll('dialog');
                            search(parseInt($('.active').attr('jp-data')));
                        });
                    } else {
                        layer.alert(data.desc, {
                            icon: 56
                        });
                    }
                }
            });
        });
    }
</script>
</body>
</html>